<#--
List of variables to be passed for this template:
        +- rootPackage
        +- applicationName
        +- classNames
        +- directory
        +- Entities: ArrayList of EntityClass.getAsMap()

            |
            +- imports: imports
            |
            +- name: The name of the class.
            |    |
            |    +- single
            |    +- plural
            |
            +- idColumn: the id column
            |    |
            |    +- field
            |    |    |
            |    |    +- name
            |    |    +- type
            |    |
            |    +- getter
            |    +- setter
            |
            +- columns: ArrayList of columns
            |    |
            |    +- field
            |    +- getter
            |    +- setter

-->
<@pp.dropOutputFile />

<@pp.changeOutputFile name="/development/${directory}/apis/rest/${applicationName?cap_first}RestApplication.java" />

package ${rootPackage}.${applicationName}.apis.rest;

import org.restlet.Application;
import org.restlet.Restlet;
import org.restlet.routing.Router;

<#list Entities as entity>
import ${rootPackage}.${applicationName}.apis.rest.resources.${entity.name.single}Resource;
import ${rootPackage}.${applicationName}.apis.rest.resources.${entity.name.plural}Resource;
</#list>

public class ${applicationName?cap_first}RestApplication extends Application{

	@Override
	public Restlet createRoot() {
		Router router = new Router(getContext());

                <#list Entities as entity>
		router.attach("${entity.name.plural}/", ${entity.name.plural}Resource.class);
		router.attach("${entity.name.plural}/{id}", ${entity.name.single}Resource.class);
                </#list>

		return router;
	}
}
